package com.ruoyi.monitormanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.monitormanage.domain.TTestteam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.monitormanage.domain.TTeammember;
import com.ruoyi.monitormanage.service.ITTeammemberService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * monitormanagebuildController
 *
 * @author ruoyi
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/teammember")
public class TTeammemberController extends BaseController
{
    @Autowired
    private ITTeammemberService tTeammemberService;

    /**
     * 查询monitormanagebuild列表
     */
   /* @RequiresPermissions("monitormanage:teammember:list")*/
    @GetMapping("/list")
    public TableDataInfo list(TTestteam tTeamteam)
    {
        startPage();
        List<TTeammember> list = tTeammemberService.selectTTeammemberList(tTeamteam);
        return getDataTable(list);
    }

    /**
     * 导出monitormanagebuild列表
     */
    @RequiresPermissions("monitormanage:teammember:export")
    @Log(title = "monitormanagebuild", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTestteam tTeamteam)
    {
        List<TTeammember> list = tTeammemberService.selectTTeammemberList(tTeamteam);
        ExcelUtil<TTeammember> util = new ExcelUtil<TTeammember>(TTeammember.class);
        util.exportExcel(response, list, "monitormanagebuild数据");
    }

    /**
     * 获取monitormanagebuild详细信息
     */
    @RequiresPermissions("monitormanage:teammember:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tTeammemberService.selectTTeammemberById(id));
    }

    /**
     * 新增monitormanagebuild
     */
    @RequiresPermissions("monitormanage:teammember:add")
    @Log(title = "monitormanagebuild", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTeammember tTeammember)
    {
        return toAjax(tTeammemberService.insertTTeammember(tTeammember));
    }

    /**
     * 修改monitormanagebuild
     */
    @RequiresPermissions("monitormanage:teammember:edit")
    @Log(title = "monitormanagebuild", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTeammember tTeammember)
    {
        return toAjax(tTeammemberService.updateTTeammember(tTeammember));
    }

    /**
     * 删除monitormanagebuild
     */
    @RequiresPermissions("monitormanage:teammember:remove")
    @Log(title = "monitormanagebuild", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTeammemberService.deleteTTeammemberByIds(ids));
    }

    /**
     * 检查监测队中是否存在监测队员
     *
     * @param ids
     * @return
     */
    @PostMapping("/selectTTeammemberByTeamId")
    public boolean selectTTeammemberByTeamId(@RequestBody Long[] ids)
    {
        if (tTeammemberService.selectTTeammemberByTeamId(ids) > 0){
            return true;
        }
            return false;
    }

}
